//
//  DoctorIcon.m
//  EcmDoctor
//
//  Created by Mac on 16/2/17.
//  Copyright © 2016年 张进. All rights reserved.
//

#import "DoctorIcon.h"
#import "NetWorkUtil.h"
#import <SSKeychain/SSKeychain.h>
#import "AppUtils.h"
@implementation DoctorIcon
+(void)requetDoctorInfoWith:(NSString *)doctorInfoId success:(void (^)(DoctorIcon * ))success failure:(void (^)(NSError *))failure{
    
    NetWorkBaseRequest *req = [[NetWorkBaseRequest alloc] init];
    //请求参数
    
    req.moduleName = @"DoctorRS";
    req.methodName = @"getDoctorSimpleInfo";
    [req setValue:doctorInfoId forKey:@"doctor_info_id"];
    
    [NetWorkUtil requestWithPOST:req success:^(NetWorkBaseResponse *responseObject) {
        NSError *error = nil;
  
        if (responseObject.code.integerValue == 1) {
            if (!responseObject.data) {
                success(nil);
                return;
            }
            
            NSData *data = [responseObject.data dataUsingEncoding:NSUTF8StringEncoding];
            NSDictionary *userAttrs = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
            if (error) {
                failure(error);
                return;
            }
            
            DoctorIcon *doctorIcon = [[DoctorIcon alloc]initWithDictionary:userAttrs];
          
            success(doctorIcon);
            
        }
        else{
            error = [NSError errorWithDomain:responseObject.msg code:responseObject.code.integerValue userInfo:nil];
            failure(error);
        }
        
    } failure:^(NSError *error) {
        failure(error);
        
    } cache:NO];
    
}

@end
